package com.shujia.controller;

import com.shujia.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/*
    将来扫描的时候，会扫描到这个注解，表示这个类是一个控制类
    @Controller
 */
@RestController
public class TestController {

    @Autowired
//    @Qualifier(value = "test")
    private TestService testService;

    @Autowired
    private Calendar calendar;


    //测试地址：springboot之前的web应用   http://localhost:端口号/项目名/请求路径  http://localhost:8080/springboot-bigdata17/hello
    //springboot项目启动的时候没有项目名 不需要项目名 http://localhost:端口号/请求路径 http://localhost:8080/hello
    @RequestMapping("hello")
    public String sayHello() {
        System.out.println("hello Springboot");

        String xiaohu = testService.say("xiaohu");
        System.out.println(xiaohu);

        return "Hello 数加 各位好！！" + xiaohu;
    }

    @RequestMapping("hello2")
    public String sayHello2() {
//        Calendar instance = Calendar.getInstance();
//        Date time = instance.getTime();
//        System.out.println(time);
        Date time = calendar.getTime();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String s = sdf.format(time);

        return "今天下雨！！" + s;
    }

}
